package model.User.mapper;


import model.User.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * Created by Sunshine、宸 on 2019/6/23.
 */
@Mapper
public interface UserMapper {
    //    保存
    @Insert("insert into user values (#{userId},#{userName},#{userEmail},#{userPhone},#{userSex},#{userAge},#{userBirthday},#{userJob},#{userLocation},#{userBirth},#{userCompany},#{userPassword},#{userConfirmpwd},#{userPower},#{userHeaderurl},#{userFreeone},#{userFreetwo},#{userFreethree},#{attentionhouseId})")
//   @Insert("INSERT INTO user VALUES (null, 'c', 'we', 'wewee', 'ggf', 3, NULL, NULL, NULL, NULL, NULL, 'c', 'gdf', 'gdf', 'c', 2, 'c', 'c', NULL, 'dgds', NULL, NULL);)")
    void Save(User user);


   //删除
    @Delete("delete from User where user_id=#{value}")
    void delById(Integer user_id);

    @Select("select * from User where user_id=#{value}")
    //根据id查找
    User findById(Integer user_id);

   @Select("select * from User where user_name=#{value}")
  //根据usernmae查找
   User findByUserName(String user_name);

    //查找所有
    @Select("select * from User")
    List<User> findAll();

    /**
     * 根据用户名进行模糊查询
     * @param user_name
     * @return
     */
    @Select("select * from User where user_name like concat('%',#{value},'%')")
    List<User> findMoHu(String user_name);

    @Update("Update User set user_name=#{userName}, user_email=#{userEmail}, user_phone=#{userPhone}, user_sex=#{userSex}, user_age=#{userAge}, user_birthday=#{userBirthday}, user_job=#{userJob}, user_location=#{userLocation}, user_birth=#{userBirth}, user_company=#{userCompany}, user_password=#{userPassword}, user_confirmPwd=#{userConfirmpwd}, user_power=#{userPower}, user_headerUrl=#{userHeaderurl}, user_freeOne=#{userFreeone}, user_freeTwo=#{userFreetwo}, user_freeThree=#{userFreethree} where user_id=#{userId}")

    void updateUser(User user);

    /**
     * 根据手机号查找
     * @param user_phone
     * @return
     */
    @Select("select * from User where user_phone=#{value}")
    User findByPhone(String user_phone);

    /**
     *
     * @param
     * @return
     */
    @Select("select * from User where user_email=#{userEmail} or user_phone=#{userPhone}")
    User findByEmail(User user);
}
